<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        html,body{
            height: 100%;
        }
        #loader8 {
            float: left;
            font-size: 10px;
            position: relative;
            left:50%;
            z-index: 1001;
            margin-left: -50px;
            margin-top: 200px;
            text-indent: -9999em;
            border-top: 1.1em solid white;
            border-right: 1.1em solid white;
            border-bottom: 1.1em solid white;
            border-left: 1.1em solid orangered;
            -webkit-animation: load8 1.1s infinite linear;
            animation: load8 1.1s infinite linear;
        }
        
        #loader8,
        #loader8:after {
            border-radius: 50%;
            width: 100px;
            height: 100px;
        }
        
        @-webkit-keyframes load8 {
            0% {
                -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
            }
            100% {
                -webkit-transform: rotate(360deg);
                transform: rotate(360deg);
            }
        }
        
        @keyframes load8 {
            0% {
                -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
            }
            100% {
                -webkit-transform: rotate(360deg);
                transform: rotate(360deg);
            }
        }

        #container{
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0px;
            left: 0px;
            background: black;
            z-index: 1000;
            filter:alpha(opacity=50);
            -moz-opacity:0.5;
            -khtml-opacity: 0.5;
            opacity: 0.5;
        }
    </style>
</head>

<body>

    <div>aaa</div>

    <!--<div id="container">
        <div id="loader8"></div>
    </div>-->
</body>
<script>

(function(){
    var Loader = function(){
        this.init();
    }
    Loader.prototype = {
        constructor:Loader,
        init:function(){
            var loadHtml = '<div id="container"><div id="loader8"></div></div>';
            this.body = document.getElementsByTagName('body')[0];
            this.loadContainer = document.createElement('div');
            this.loadDiv = document.createElement('div');
            this.loadContainer.id = "container";
            this.loadDiv.id="loader8";
            this.loadContainer.appendChild(this.loadDiv);
            this.body.appendChild(this.loadContainer);
        },
        remove:function(){
            //可以先渐隐消失再remove()
            this.body.removeChild(this.loadContainer);
        }
    }
    var myLoader = new Loader();
    setTimeout(function(){
        myLoader.remove();
    },2000);
})()

</script>

</html>